﻿
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Practices.Unity;
using Apps.Models;
using Apps.Common;
using Apps.BLL.Core;
using Apps.IBLL.MIS;
using Apps.IDAL.MIS;
using Apps.Models.MIS;
using Apps.Locale;

namespace Apps.BLL.MIS
{
    public partial class MIS_Article_CategoryBLL
    {
        public List<MIS_Article_CategoryModel> GetList(string parentId)
        {
            IQueryable<MIS_Article_Category> queryData = null;
            queryData = m_Rep.GetList(a => a.ParentId == parentId).OrderBy(a => a.Sort);
            return CreateModelList(ref queryData);
        }
       
        public List<MIS_Article_CategoryModel> GetListByParentId(string id)
        {
            List<MIS_Article_Category> query = m_Rep.GetList(a => a.ParentId == id).OrderBy(a => a.Sort).ToList();
            List<MIS_Article_CategoryModel> queryResult = new List<MIS_Article_CategoryModel>();
            foreach (MIS_Article_Category entity in query)
            {
                queryResult.Add(new MIS_Article_CategoryModel()
                {
                    Id = entity.Id,
                    Name = entity.Name,
                    ParentId = entity.ParentId,
                    Sort = entity.Sort,
                    ImgUrl = entity.ImgUrl,
                    BodyContent = entity.BodyContent,
                    ChannelId = entity.ChannelId == null ? 0 : Convert.ToInt16(entity.ChannelId),
                    CreateTime = entity.CreateTime,

                });
            }
            return queryResult;
        }
     
    }
}